%%%-------------------------------------------------------------------
%%% @author Rain
%%% @copyright (C) 2022, <COMPANY>
%%% @doc
%%% @end
%%%-------------------------------------------------------------------
-module(rank_sup).

-behaviour(supervisor).

-export([start_link/0, init/1, start_rank_svr/1]).
-include("rank.hrl").

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init([]) ->
    {ok, {#{strategy => one_for_one,
        intensity => 5,
        period => 30},
        []}
    }.

start_rank_svr(RankType) ->
    RankSvrChild = #{id => ?RANK_SVR_NAME(RankType),
        start => {rank_svr, start_link, [RankType]},
        restart => permanent,
        shutdown => 2000,
        type => worker,
        modules => [rank_svr]},
    supervisor:start_child(?MODULE, RankSvrChild).